﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO
{
    public class AccessoriesDAO
    {
        CameraDBEntities db = new CameraDBEntities();
        public List<Accessory> GetListAll()
        {
            return db.Accessories.Where(x => x.accesStatus == true).ToList();
        }
        public List<Accessory> GetListTop10()
        {
            return db.Accessories.Where(x => x.accesStatus == true).Take(10).ToList();
        }
        public Accessory GetById(int id)
        {
            return db.Accessories.Where(x => x.accesId == id && x.accesStatus == true).SingleOrDefault();
        }

        public List<Accessory> GetListSearch(string tukhoa)
        {
            List<Accessory> listkq = new List<Accessory>();
            listkq = db.Accessories.Where(x => x.accesStatus == true).ToList();
            listkq = listkq.FindAll(

                delegate(Accessory math)
                {
                    if (Utils.ConvertToUnSign(math.accesNames.ToLower()).Contains(tukhoa))
                        return true;
                    else
                        return false;
                }
            );
            return listkq;
        }
    }
}
